/// Extension on the [Iterable]
extension JMIterableExtension<T> on Iterable<T> {
  /// JMIterableExtension: Split one large list to limited sub lists.
  ///
  /// Example:
  /// ```dart
  /// [1, 2, 3, 4, 5, 6, 7, 8, 9].chunks(2)
  /// // => [[1, 2], [3, 4], [5, 6], [7, 8], [9]]
  /// ```
  Iterable<List<T>> chunks(int chunkSize) sync* {
    for (int i = 0; i < length; i += chunkSize) {
      final start = i > length ? i - length : i;
      yield skip(start).take(chunkSize).toList();
    }
  }
}
